{
LANG : PASCAL
PROB : holstein
}

program HOLSTEIN;
const
  fi = 'holstein.in';
  fo = 'holstein.out';
type
  vitamin = array[1..25] of longint;
var
  p, free : array[1..15] of boolean;
  feed : array[1..15] of vitamin;
  min, cur : vitamin;
  v, g, minimum : longint;

procedure inp;
var
  i, j : longint;
begin
  read(v);
  for i := 1 to v do read(min[i]);
  read(g);
  for i := 1 to g do
    for j := 1 to v do read(feed[i, j]);
end;

function ok : boolean;
var
  i : longint;
begin
  ok := false;
  for i := 1 to v do
    if cur[i] < min[i] then exit;
  ok := true;
end;

procedure attemp(k, sum : longint);
var
  i : longint;
begin
  if k = g+1 then
  begin
    if (sum <= minimum) and ok then
    begin
      minimum := sum;
      p := free;
    end;
    exit;
  end;
  attemp(k+1, sum);
  free[k] := false;
  for i := 1 to v do inc(cur[i], feed[k, i]);
  attemp(k+1, sum+1);
  for i := 1 to v do dec(cur[i], feed[k, i]);
  free[k] := true;
end;

procedure process;
begin
  minimum := 100;
  fillchar(cur, sizeof(cur), 0);
  fillchar(free, sizeof(free), true);
  attemp(1, 0);
end;

procedure out;
var
  i : longint;
begin
  write(minimum);
  for i := 1 to g do
    if not p[i] then write(' ', i);
  writeln;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);

  inp;
  process;
  out;

  close(output);
  close(input);
end.
